<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //父类 基类
        function Person(name,age) {
            this.name = name;
            this.age = age;
        }
        Person.prototype.eat = function(){
            console.log('吃饭');
        }
        
        //子类
        function Student(id,name,age) {
            //构造函数继承
            Person.call(this,name,age);
            this.id = id;
        }

        //原型链继承(不能直接把父类的原型对象赋值给子类的原型对象,否则会共享)
        Student.prototype = new Person;

        //修正constructor
        Student.prototype.constructor = Student;

        Student.prototype.study = function(){
            console.log('学习');
        }
    </script>
</body>
</html>